/* 
 * 功能： 数据库连接，存储过程调用
 */
package softdone;
import java.sql.*;

public class Conn{

private Connection conn;
public ResultSet rs;
public CallableStatement cs;
public void Create(){
	try{
//		String connectionUrl;
//		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//		connectionUrl = "jdbc:sqlserver://localhost:1433;" +  "databaseName=Soft;user=sa;password=sa;";
//		conn = DriverManager.getConnection(connectionUrl);
		conn = Proxool.getInstance().getConnection();
	}catch(Exception e){
		e.printStackTrace();
	}
}
public void CloseRC(){
	try{
		rs.close();
		conn.close();
	}catch(Exception e){
		e.printStackTrace();
	}
}
public void CloseC(){
	try{
		conn.close();
	}catch(Exception e){
		e.printStackTrace();
	}
}
public void CloseCC(){
	try {
		if (cs != null) {
			cs.close();
			cs = null;
		}
		if (conn != null) {
			conn.close();
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
}
public ResultSet Res_SQL(String sql){
	try{
		Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
		rs=stmt.executeQuery(sql);
	}catch(Exception e){
		e.printStackTrace();
	}
	return rs;
}
public boolean Use_SQL(String sql){
	/*�޷���ֵ�ĵ���sql���
	 * 
	 */
	boolean check=false;
	try{
	Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
	stmt.execute(sql);
	check=true;
	}catch(Exception e){
		e.printStackTrace();
	}
	return check;
}
public CallableStatement CSt_SQL(String sql){
	try{
		cs=conn.prepareCall(sql);
	}catch(Exception e){
		e.printStackTrace();
	}
	return cs;
}
}
